from PIL import Image 
import os
photo_size_1_inch = (295,413)
photo_size_2_inch = (413,626)
#photo_outType = (0,0)
photo_outType = ()

def Image_PreProcessing():
	# 待处理图片存储路径	
	im = Image.open(photo_inPath)
	# Resize图片大小，入口参数为一个tuple，新的图片大小
	imBackground = im.resize(photo_outType)
	#处理后的图片的存储路径，以及存储格式
	imBackground.save(photo_outPath,'JPEG')

while True:
	photo_inPath = input("请输入照片所在的绝对路径\n")
	if os.path.isfile(photo_inPath):
		break
	else:
		print("文件不存在，请重新输入")

photo_outPath = os.path.dirname(photo_inPath) + "\passportphoto.jpg"
print("请选择照片类型")
print("1.一寸照片")
print("2.二寸照片")

while True:
		photo_Type = input("请输入序号:")
		if photo_Type == "1" :
			photo_outType = photo_size_1_inch
			break
		elif photo_Type == "2" :
			photo_outType = photo_size_2_inch
			break
		else :
			print ("输入有误，请重新输入：")
			
Image_PreProcessing()

def Image_PreProcessing():
	# 待处理图片存储路径	
	im = Image.open(photo_inPath)
	# Resize图片大小，入口参数为一个tuple，新的图片大小
	imBackground = im.resize(photo_outType)
	#处理后的图片的存储路径，以及存储格式
	imBackground.save(photo_outPath,'JPEG')